<?php
class LoginAction extends Action{

	public function index(){
		$this->display();
	}

	/*
	 * 登录
	 */
	public function login(){
		$login = new LoginModel();
		$data = $login->create();
		$username = $_POST['username'];
		$password = md5($_POST['password']);
		$result = $login->loginIn($username, $password);
		if ($result){
			$this->redirect("/Index/index");
		}else {
			$username = $_POST['username'];
			$this->assign('uname',$username);
			$error = $login->getError();
			if ($error == ''){
				$error = "用户名和密码不匹配！";
			}
			$this->assign("login_error",$error);
			$this->display("Login:index");
		}
	}
}